import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;


public class FileNotExistChecker {

    protected File target;


    public FileNotExistChecker(File target) {
        this.target = target;
    }

    public List<ComparisonResult> checkAndReturnConflicteds(List<ComparisonResult> comparisonResults) throws IOException {

        List<ComparisonResult> ret = new LinkedList<ComparisonResult>();


        for (ComparisonResult comparisonResult : comparisonResults) {

            String filename = comparisonResult.getRelativeFilename();
            File file = new File(target, filename);

            if (file.exists()) {

                comparisonResult.setType(ComparisonResult.ResultType.EXISTS_BUT_SHOULD_NOT);
                ret.add(comparisonResult);
            }

        }

        return ret;

    }


}
